<template>
  <div class="container">
    <img class="banner" src="@/assets/user-banner.png" alt="" />
    <div class="wrap">
      <div class="info">
        <img :src="info.avatar" alt="" />
        <div class="text">
          <div class="name">{{ info.nickname }}</div>
          <div class="lable">{{ info.email }}</div>
          <div class="content">
            {{ info.bio }}
          </div>
        </div>
      </div>
      <div class="introduce">
<!--        <div class="text">-->
<!--          <div class="title">**专业背景**</div>-->
<!--          <p>- 从业X年，服务过[知名客户/品牌/媒体名称，如有]</p>-->
<!--          <p>- 毕业于[相关院校/专业，如有] 或 [自学经历亮点]</p>-->
<!--          <p>- 擅长[具体技术或风格，如自然光人像/创意合成/无人机航拍等]</p>-->
<!--          <div class="title">**作品与成就**</div>-->
<!--          <p>- 作品曾发表于[杂志/平台名称]（如有）</p>-->
<!--          <p>- 合作客户：[列出代表性客户或品牌]</p>-->
<!--          <p>- 获得[奖项/认证]（如IPA、PX3等国际奖项或行业认证）</p>-->
<!--        </div>-->
<!--        <img src="@/assets/about-img1.png" alt="" />-->
      </div>
      <div class="workTitle">作品展示</div>
      <div class="works">
        <div class="col" v-for="item in list" :key="item.id">
          <div class="imgDiv">
            <img :src="item.image_url" alt="" />
            <div class="content">
              <!-- <div class="left">
                <p>{{ item.title_cn }}</p>
                <div class="info">
                  <img :src="item.image" alt="" />
                  {{ item.location }}
                </div>
              </div> -->
              <div class="right">
                <span class="pointer" @click.prevent="collect(item)">
                  <i class="el-icon-star-off"></i>
                </span>
                <span class="pointer" @click.prevent="download(item)">
                  <i class="el-icon-download"></i>
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <pagination
        :total="total"
        :currentPage="page"
        :pageSize="rows"
        @handleCurrentChange="handleCurrentChange"
      />
    </div>
    <payment :show.sync="show" />
  </div>
</template>
  
 <script>
export default {
  name: "NavBar",
  data() {
    return {
      info: {},
      userId: "",
      page: 1,
      rows: 9,
      total: 0,
      list: [],
      show: false,
    };
  },
  components: {
    pagination: () => import("@/components/pagination.vue"),
    payment: () => import("@/components/payment.vue"),
  },
  mounted() {
    this.userId = this.$route.query.id;
    this.getInfo();
    this.getList();
  },
  methods: {
    getInfo() {
      this.$post("/index/cameraman_detail", { user_id: this.userId }).then(
        (res) => {
          this.info = res.data;
        }
      );
    },
    getList() {
      this.$post("/index/cameraman_images_list", { user_id: this.userId }).then(
        (res) => {
          this.list = res.data.data;
          this.total = res.data.total;
        }
      );
    },
    handleCurrentChange(e) {
      this.page = e;
      this.getList();
    },
    download(item) {
      this.show = true;
    },
    collect(item) {
      this.$post("/user/favorite", { image_sn: item.image_sn }).then((res) => {
        this.$message.success("收藏成功");
      });
    },
  },
};
</script>
  
<style scoped lang="scss">
.container {
  color: #808080;
  font-size: 22px;
}
.banner {
  height: 300px;
}
.info {
  display: flex;
  margin-top: 90px;

  img {
    width: 360px;
    height: 370px;
  }
  .text {
    width: calc(100% - 360px);
    padding-left: 46px;
    .name {
      color: #333;
      font-size: 36px;
      margin-bottom: 20px;
    }
    .content {
      border-top: 2px dotted #999;
      padding-top: 20px;
      margin-top: 20px;
    }
  }
}
.introduce {
  padding: 50px 0;
  display: flex;
  .text {
    width: calc(100% - 455px);
    padding-right: 30px;
    line-height: 2;
    .title {
      color: #333;
    }
  }
  img {
    width: 455px;
  }
}
.workTitle {
  font-size: 26px;
  color: #333;
  border-top: 2px dotted #999;
  padding-top: 50px;
}
.works {
  display: flex;
  flex-wrap: wrap;
  padding: 40px 0 70px;
  .col {
    width: calc(100% / 3);
    padding: 8px;
    .imgDiv {
      border-radius: 8px;
      height: 500px;
      position: relative;
      .content {
        position: absolute;
        width: 100%;
        bottom: 0;
        left: 0;
        background: rgba($color: #8f79c4, $alpha: 0.7);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 17px;
        transform: translateY(100%);
        transition: all 0.3s;
        p {
          font-size: 18px;
          font-weight: bold;
          margin-bottom: 5px;
        }
        .info {
          font-size: 14px;
          display: flex;
          img {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            display: block;
            margin-right: 10px;
          }
        }
        .right {
          display: flex;
          span {
            display: flex;
            align-items: center;
            justify-content: center;
            background: #441054;
            border-radius: 3px;
            width: 28px;
            height: 28px;
            margin-left: 10px;
          }
        }
      }
      &:hover .content {
        transform: translateY(0);
      }
    }
  }
}
@media screen and (max-width: 768px) {
  .info {
    margin-top: 60px;
    display: block;
  }
  .info img {
    width: 100%;
    max-height: 300px;
  }
  .info .text {
    width: 100%;
    padding-left: 0;
  }
  .info .text .name {
    font-size: 26px;
    margin-bottom: 10px;
  }
  .container {
    font-size: 16px;
  }
  .introduce {
    padding: 50px 0;
    display: block;
    img {
      width: 100%;
    }
  }
  .introduce .text {
    width: 100%;
    padding-right: 0;
  }
  .works .col {
    width: 100%;
    .imgDiv {
      border-radius: 8px;
      height: 220px;
    }
  }
}
</style>
  